﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;

namespace Sharp.Platform.Other
{
    /// <summary>
    /// 工具栏按钮
    /// </summary>
    public class ToolButtonInfo
    {
        /// <summary>
        /// 工具栏按钮 构造函数
        /// </summary>
        public ToolButtonInfo()
        {
            Model = string.Empty;
            Title = string.Empty;
            Icon = string.Empty;
            Url = string.Empty;
            AjaxFunction = string.Empty;
            IsIFrameStyle = 0;

            WithoutId = true;
            IsSendParentId = true;
        }

        /// <summary>
        /// 数据处理器模式，用于和浏览器之间传递处理指令
        /// </summary>
        public string Model { get; set; }

        /// <summary>
        /// 数据处理器名称（按钮标题）
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 图标
        /// </summary>
        public string Icon { get; set; }

        /// <summary>
        /// 模块ID或者Iframe Url
        /// </summary>
        public string Url { get; set; }

        /// <summary>
        /// Iframe Style
        /// 0：以iframe打开链接；1：以窗体打开链接；2：url的资源是否当作js来执行
        /// </summary>
        public int IsIFrameStyle { get; set; }

        /// <summary>
        ///  Ajax请求，无窗体
        /// </summary>
        public bool IsAjax { get; set; }

        /// <summary>
        /// 窗体宽度
        /// </summary>
        public int Width { get; set; }

        /// <summary>
        /// 窗体高度
        /// </summary>
        public int Height { get; set; }

        /// <summary>
        /// 不需要发送数据记录 ID
        /// </summary>
        public bool WithoutId { get; set; }

        /// <summary>
        /// 发送ParentId
        /// </summary>
        public bool IsSendParentId { get; set; }
        /// <summary>
        /// 客户端点击
        /// </summary>
        public string OnClientClick { get; set; }
         
        /// <summary>
        /// 客户端 Ajax 函数
        /// </summary>
        public string AjaxFunction { get; set; }


        /// <summary>
        /// 将要渲染的Html
        /// </summary>
        public string Html { get; set; }

        public DirectClickAction Direct  { get; set; }

        public IList<Parameter> Parameters { get; set; }

        public class DirectClickAction
        {
            public DirectClickAction( string actionName,string controllerName)
            {
                ControllerName = controllerName;
                ActionName = actionName;
            }
            public string ControllerName { get; set; }
            public string ActionName { get; set; }

        }
        public class Parameter
        {
            /// <summary>
            /// 
            /// </summary>
            /// <param name="name"></param>
            /// <param name="value"></param>
            /// <param name="mode">类似Ext.net的ParameterMode枚举</param> 
            public Parameter(string name, string value, int mode)
            {
                Name = name;
                Value = value;
                Mode = mode;
            }
            public string Name { get; set; }
            public string Value { get; set; }
            public int Mode { get; set; }
        }
    }
}